﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="AddDVD.aspx.cs" Inherits="AdminPages_AddDVD" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="SqlDataSource1" 
        AutoGenerateColumns="False" DataKeyNames="MovieID" 
        onrowcommand="GridView1_RowCommand">
        <Columns>
            <asp:BoundField DataField="MovieID" HeaderText="MovieID" InsertVisible="False" 
                ReadOnly="True" SortExpression="MovieID" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            <asp:BoundField DataField="Stock" HeaderText="Stock" ReadOnly="True" 
                SortExpression="Stock" />
            <asp:ButtonField ButtonType="Button" CommandName="addDVD" Text="+" />
            <asp:ButtonField ButtonType="Button" CommandName="removeDVD" Text="-" />
            <asp:ButtonField ButtonType="Button" CommandName="setnull" Text="0" />
        </Columns>
    </asp:GridView>

    <asp:DropDownList ID="ddl_NewMovie" runat="server" 
        DataSourceID="SqlDataSource2" DataTextField="Title" DataValueField="MovieID">
    </asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
        SelectCommand="SELECT [MovieID], [Title] FROM [Movie]"></asp:SqlDataSource>

    <asp:Button ID="btn_AddNewDvd" runat="server" Text="Add New DVD" 
        onclick="btn_AddNewDvd_Click" />

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
        SelectCommand="SELECT Movie.MovieID, Movie.Title, COUNT(DVDStock.DVDStockID) AS Stock FROM Movie INNER JOIN DVDStock ON Movie.MovieID = DVDStock.MovieID GROUP BY Movie.MovieID, Movie.Title">
    </asp:SqlDataSource>


</asp:Content>

